# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=postgresql-pgvector
_projname=pgvector
pkgver=0.5.1
pkgrel=2
pkgdesc="Open-source vector similarity search for PostgreSQL"
url="https://github.com/pgvector/pgvector"
arch="all"
license="PostgreSQL"
makedepends="postgresql-dev"
subpackages="$pkgname-dev $pkgname-bitcode"
source="https://github.com/pgvector/pgvector/archive/v$pkgver/$_projname-$pkgver.tar.gz"
builddir="$srcdir/$_projname-$pkgver"
options="!check"  # tests require running PostgreSQL

build() {
	# OPTFLAGS: avoid building with -march=native.
	make OPTFLAGS=""
}

package() {
	depends="postgresql$(pg_config --major-version)"

	make DESTDIR="$pkgdir" install
}

bitcode() {
	pkgdesc="$pkgdesc (bitcode for JIT)"
	depends="$pkgname=$pkgver-r$pkgrel"
	install_if="postgresql$(pg_config --major-version)-jit $pkgname=$pkgver-r$pkgrel"

	amove usr/lib/postgresql*/bitcode
}

sha512sums="
1de14bbe8237ab3759a6f5d1d160f9f63bee2f60079ca31c310514475cbdfbd376188ec98af54ae98a22b9a82c4462907f5fc65ca42215cf1468c166021c2154  pgvector-0.5.1.tar.gz
"
